package fast;

import com.gitee.sophis.annotations.EnableApiDocument;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author xiejiarong
 */
@SpringBootApplication
@EnableApiDocument(title = "spring boot 快速开发脚手架",description = "后台接口文档",
groupName = "server")
public class SpringBootFastCliApplication{

    public static void main(String[] args) {
        SpringApplication.run(SpringBootFastCliApplication.class, args);
    }


    @Bean
    public WebMvcConfigurer cors(){
        return new WebMvcConfigurer() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**")
                        .allowedOrigins("*")
                        .allowCredentials(true)
                        .allowedMethods("GET", "POST", "DELETE", "PUT","PATCH")
                        .maxAge(3600);
            }
        };
    }

}
